package com.shunli.cterminal.mapper;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.examples.core.enums.YesOrNoEnum;
import com.examples.core.mybatis.mapper.KyLambdaQueryWrapper;
import com.shunli.cterminal.entity.SystemProject;

import java.util.List;

public interface SystemProjectMapper extends BaseMapper<SystemProject> {

    /**
     * 根据编码查询项目方，如果没有传入编码将查询全部的项目方
     * @param codeList
     * @return
     */
    default List<SystemProject> queryProjectInfoByCodeList(List<String> codeList) {
        if(CollectionUtil.isEmpty(codeList)){
            return selectList(Wrappers.<SystemProject>lambdaQuery().eq(SystemProject::getStatus, YesOrNoEnum.YES.getCode()));
        }
        return selectList(new KyLambdaQueryWrapper<SystemProject>()
                .in(SystemProject::getCode, codeList));
    }
}
